package com.apps.ftapp.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.apps.ftapp.R;
import com.apps.ftapp.util.Tools;

import java.util.List;
import java.util.Map;

/**
 * Created by lyli on 2017/11/21.
 */

public class ZhenTiGridAdapter extends BaseAdapter {

    private Context mContext;
    List<Map> dataList;

    public ZhenTiGridAdapter(Context mContext, List<Map> dataList) {
        super();
        this.mContext = mContext;
        this.dataList = dataList;
    }

    @Override
    public int getCount() {
        if (dataList == null) {
            return 0;
        } else {
            return this.dataList.size();
        }
    }

    @Override
    public Object getItem(int i) {
        if (dataList == null) {
            return null;
        } else {
            return this.dataList.get(i);
        }
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        Map zp = dataList.get(i);
        ViewHolder holder = null;
        if (view == null) {
            view = LayoutInflater.from(this.mContext).inflate(R.layout.zhenti_dange, null, false);
            holder = new ViewHolder(view);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        holder.biaoti.setText(Tools.isNull(zp.get("title")));
        return view;
    }


    private class ViewHolder {
        TextView biaoti;

        public ViewHolder(View view) {
            biaoti = view.findViewById(R.id.biaoti);
        }
    }


}
